<?php
$link = mysqli_connect("localhost","root","root","2113");
$arr = [];
$p=$_GET['p'];
$perPage = $_GET['perPage'];
$start=($p-1)*$perPage;

$sql = "SELECT * FROM products ORDER BY id DESC LIMIT $start,$perPage ";
$res =  mysqli_query($link,$sql);
while($one=mysqli_fetch_assoc($res)){
    $arr[] = $one;
}
echo json_encode($arr);
?>